// SysUserRoleController.java
package com.lawliet.example.controller.system;

import com.lawliet.example.model.system.SysUserRole;
import com.lawliet.example.model.vo.Result;
import com.lawliet.example.service.system.SysUserRoleService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "SysUserRole 接口")
@RestController
@RequestMapping("/api/sysUserRole")
public class SysUserRoleController {

    @Autowired
    private SysUserRoleService sysUserRoleService;

    @GetMapping("/list")
    public Result<List<SysUserRole>> list() {
        return Result.OK(sysUserRoleService.list());
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody SysUserRole sysUserRole) {
        return Result.OK(sysUserRoleService.save(sysUserRole));
    }

    @PutMapping("/edit")
    public Result<?> edit(@RequestBody SysUserRole sysUserRole) {
        return Result.OK(sysUserRoleService.updateById(sysUserRole));
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> delete(@PathVariable Long id) {
        return Result.OK(sysUserRoleService.removeById(id));
    }

    @GetMapping("/query/{id}")
    public Result<SysUserRole> queryById(@PathVariable Long id) {
        return Result.OK(sysUserRoleService.getById(id));
    }
}
